# Maintainer: ImperatorS79 <fevrier.simon@gmail.com>

_realname=sol2
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.3.0
pkgrel=1
pkgdesc="sol2 is a C++ library binding to Lua"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://sol2.readthedocs.io/"
license=('spdx:MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-ninja")
depends=("${MINGW_PACKAGE_PREFIX}-lua")
source=(https://github.com/ThePhD/sol2/archive/v${pkgver}.tar.gz)
sha256sums=('b82c5de030e18cb2bcbcefcd5f45afd526920c517a96413f0b59b4332d752a1e')

prepare() {
  plain 'No Step'
}

build() {
  cd "${srcdir}/sol2-${pkgver}"
  rm -rf buid-${MSYSTEM} && mkdir build-${MSYSTEM} && cd build-${MSYSTEM}

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -GNinja \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    ..

  ${MINGW_PREFIX}/bin/cmake --build . 
}

package() {
  cd "${srcdir}/sol2-${pkgver}/build-${MSYSTEM}"
  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake --install .
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE.txt" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE.txt"
}
